package java_thinking.unit_11._11_6;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Iterator;

/**
 * @Description :
 * @author: cww
 * @DateTime: 2019-03-17 17:11
 */

class Rodent {
    public void hop() { System.out.println("Rodent hopping"); }
    public void scurry() { System.out.println("Rodent scurrying"); }
    public void reproduce() { System.out.println("Making more Rodents"); }
    @Override
    public String toString() { return "Rodent"; }
}

class Mouse extends Rodent {
    @Override
    public void hop() { System.out.println("Mouse hopping"); }
    @Override
    public void scurry() { System.out.println("Mouse scurrying"); }
    @Override
    public void reproduce() { System.out.println("Making more Mice"); }
    @Override
    public String toString() { return "Mouse"; }
}

class Hamster extends Rodent {
    @Override
    public void hop() { System.out.println("Hamster hopping"); }
    @Override
    public void scurry() { System.out.println("Hamster scurrying"); }
    @Override
    public void reproduce() { System.out.println("Making more Hamsters"); }
    @Override
    public String toString() { return "Hamster"; }
}

class E10_RodentIterator {
    public static void main(String args[]) {
        ArrayList<Rodent> rodents = new ArrayList<Rodent>(Arrays.asList(new Rodent(), new Mouse(), new Hamster()));
        Rodent r;
        for(Iterator<Rodent> it = rodents.iterator();it.hasNext();) {
            r = it.next();
            r.hop();
            r.scurry();
            r.reproduce();
            System.out.println(r);
        }
    }
}